

function addSensorbitCod(Blockly) {




    //普通超声波传感器模块初始化
  Blockly.Python.microbit_ultrasonicInit = function(block) {
    var dropdown_trigPort = this.getFieldValue('trigPort');
    var dropdown_echoPort = this.getFieldValue('echoPort');
    Blockly.Python.definitions_['import_microbit'] = 'from microbit import *';
    Blockly.Python.definitions_['import_ultrasonic'] = 'from sensor import ultrasonic';
    Blockly.Python.definitions_['import_ultrasonicInit'] = 'ultrasonic.init_hc_sr04('+dropdown_trigPort+', '+dropdown_echoPort+')\n';
    return "";
  }

  //普通超声波传感器模块获取距离
  Blockly.Python.microbit_ultrasonicDistance = function(block) {
    var code = "ultrasonic.get_hc_sr04_distance()";
    return [code];
  }

    return Blockly;
}

module.exports = addSensorbitCod;

